package edu.wong.pro.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import edu.wong.pro.iservice.IAdvise;

public class AdviseAction extends ActionSupport{
	private IAdvise iAdvise;

	public IAdvise getiAdvise() {
		return iAdvise;
	}

	public void setiAdvise(IAdvise iAdvise) {
		this.iAdvise = iAdvise;
	}
	
	//对计划活动发表意见
	public void relAdvise(){
		HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();
		String planId = request.getParameter("planId");
		String advContent = request.getParameter("advContent");
		iAdvise.relAdvise(planId, advContent);
	}
	
	//获取当前计划活动的所有意见
	public void getAdviseByPlanId() throws IOException{
		HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();
		String planId = request.getParameter("planId");
		HttpServletResponse response = (HttpServletResponse) ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter writer = response.getWriter();
		writer.print(iAdvise.getAdviseByPlanId(planId));
		writer.flush();
		writer.close();
	}
}
